//author:kakake
var Model = /** @class */ (function () {
    function Model() {
    }
    return Model;
}());

//author:kakake
var Common = /** @class */ (function () {
    function Common() {
    }
    return Common;
}());

//author:kakake
var reportController = /** @class */ (function () {
    function reportController() {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn()
        };
    }
    //动态生成报表文件
    reportController.prototype.getreportfile = function () {
        var formid = TSLobsterAPI.Program.RequestQuery("formid", 0);
        var otherck = {
            CreateTime: TSLobsterAPI.Program.RequestQuery("CreateTime", "false"),
            UpdateTime: TSLobsterAPI.Program.RequestQuery("UpdateTime", "false"),
            WriteTimeLong: TSLobsterAPI.Program.RequestQuery("WriteTimeLong", "false"),
            WriteDevice: TSLobsterAPI.Program.RequestQuery("WriteDevice", "false"),
            WriteOS: TSLobsterAPI.Program.RequestQuery("WriteOS", "false"),
            WriteBrower: TSLobsterAPI.Program.RequestQuery("WriteBrower", "false"),
            WriteLocation: TSLobsterAPI.Program.RequestQuery("WriteLocation", "false"),
            WriteIP: TSLobsterAPI.Program.RequestQuery("WriteIP", "false")
        };
        var reportjson = {
            "Version": "6.6.8.1",
            "Title": "formreport",
            "Author": "kakake",
            "Description": "",
            "Font": {
                "Name": "宋体",
                "Size": 90000,
                "Weight": 400,
                "Charset": 134
            },
            "Printer": {
                "TopMargin": 1.5,
                "BottomMargin": 1.5
            },
            "DetailGrid": {
                "CenterView": true,
                "PrintAdaptMethod": "ResizeToFit",
                "AppendBlankCol": true,
                "Recordset": {
                    "Field": [
                        {
                            "Name": "CustomerID"
                        },
                        {
                            "Name": "CompanyName"
                        },
                        {
                            "Name": "ContactName"
                        },
                        {
                            "Name": "ContactTitle"
                        },
                        {
                            "Name": "Address"
                        },
                        {
                            "Name": "City"
                        },
                        {
                            "Name": "Region"
                        },
                        {
                            "Name": "PostalCode"
                        },
                        {
                            "Name": "Country"
                        },
                        {
                            "Name": "Phone"
                        },
                        {
                            "Name": "Fax"
                        }
                    ]
                },
                "Column": [
                    {
                        "Name": "CustomerID",
                        "Width": 1.98438
                    },
                    {
                        "Name": "CompanyName",
                        "Width": 3.38667
                    },
                    {
                        "Name": "ContactName",
                        "Width": 1.5875
                    },
                    {
                        "Name": "ContactTitle",
                        "Width": 1.98438
                    },
                    {
                        "Name": "Address",
                        "Width": 3.81
                    },
                    {
                        "Name": "City",
                        "Width": 2.01083
                    },
                    {
                        "Name": "Region",
                        "Width": 1.98438
                    },
                    {
                        "Name": "PostalCode",
                        "Width": 1.5875
                    },
                    {
                        "Name": "Country",
                        "Width": 1.5875
                    },
                    {
                        "Name": "Phone",
                        "Width": 3.41313
                    },
                    {
                        "Name": "Fax",
                        "Width": 3.41313
                    }
                ],
                "ColumnContent": {
                    "Height": 0.79375,
                    "ColumnContentCell": [
                        {
                            "Column": "CustomerID",
                            "BackColor": "FFFF00",
                            "DataField": "CustomerID"
                        },
                        {
                            "Column": "CompanyName",
                            "BackColor": "FFFF00",
                            "DataField": "CompanyName"
                        },
                        {
                            "Column": "ContactName",
                            "DataField": "ContactName"
                        },
                        {
                            "Column": "ContactTitle",
                            "DataField": "ContactTitle"
                        },
                        {
                            "Column": "Address",
                            "DataField": "Address"
                        },
                        {
                            "Column": "City",
                            "DataField": "City"
                        },
                        {
                            "Column": "Region",
                            "DataField": "Region"
                        },
                        {
                            "Column": "PostalCode",
                            "DataField": "PostalCode"
                        },
                        {
                            "Column": "Country",
                            "DataField": "Country"
                        },
                        {
                            "Column": "Phone",
                            "DataField": "Phone"
                        },
                        {
                            "Column": "Fax",
                            "DataField": "Fax"
                        }
                    ]
                },
                "ColumnTitle": {
                    "BackColor": "E2EFF1",
                    "Height": 0.79375,
                    "Font": {
                        "Name": "宋体",
                        "Size": 90000,
                        "Bold": true,
                        "Charset": 134
                    },
                    "RepeatStyle": "OnPage",
                    "ColumnTitleCell": [
                        {
                            "GroupTitle": false,
                            "Column": "CustomerID",
                            "TextAlign": "MiddleCenter",
                            "Text": "客户编号"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "CompanyName",
                            "TextAlign": "MiddleCenter",
                            "Text": "公司名称"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "ContactName",
                            "TextAlign": "MiddleCenter",
                            "Text": "联系人"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "ContactTitle",
                            "TextAlign": "MiddleCenter",
                            "Text": "联系人称谓"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "Address",
                            "TextAlign": "MiddleCenter",
                            "Text": "地址"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "City",
                            "TextAlign": "MiddleCenter",
                            "Text": "城市"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "Region",
                            "TextAlign": "MiddleCenter",
                            "Text": "地区"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "PostalCode",
                            "TextAlign": "MiddleCenter",
                            "Text": "邮编"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "Country",
                            "TextAlign": "MiddleCenter",
                            "Text": "国家"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "Phone",
                            "TextAlign": "MiddleCenter",
                            "Text": "电话"
                        },
                        {
                            "GroupTitle": false,
                            "Column": "Fax",
                            "TextAlign": "MiddleCenter",
                            "Text": "传真"
                        }
                    ]
                }
            }
        };
        var strsql = "SELECT FormItem FROM PSQ_Form where Id=@formid";
        var dbparams = {
            formid: formid
        };
        var data = TSLobsterAPI.DbHelper.DbGetJsonObject(this.data.dbConn, strsql, dbparams);
        // PublicFunction.TrackLog("getreportfile", 0, data);
        if (data.FormItem) {
            var columnList = JSON.parse(data.FormItem);
            if (otherck.CreateTime == "true") {
                columnList.push({ "label": "填写时间", "name": "CreateTime" });
            }
            if (otherck.UpdateTime == "true") {
                columnList.push({ "label": "更新时间", "name": "UpdateTime" });
            }
            if (otherck.WriteTimeLong == "true") {
                columnList.push({ "label": "填写时长（秒）", "name": "WriteTimeLong" });
            }
            if (otherck.WriteDevice == "true") {
                columnList.push({ "label": "设备", "name": "WriteDevice" });
            }
            if (otherck.WriteOS == "true") {
                columnList.push({ "label": "系统", "name": "WriteOS" });
            }
            if (otherck.WriteBrower == "true") {
                columnList.push({ "label": "浏览器", "name": "WriteBrower" });
            }
            if (otherck.WriteLocation == "true") {
                columnList.push({ "label": "地区", "name": "WriteLocation" });
            }
            if (otherck.WriteIP == "true") {
                columnList.push({ "label": "IP地址", "name": "WriteIP" });
            }
            reportjson.DetailGrid.Recordset.Field = [];
            reportjson.DetailGrid.Column = [];
            reportjson.DetailGrid.ColumnContent.ColumnContentCell = [];
            reportjson.DetailGrid.ColumnTitle.ColumnTitleCell = [];
            columnList.forEach(function (item) {
                reportjson.DetailGrid.Recordset.Field.push({ "Name": item.name });
                reportjson.DetailGrid.Column.push({ "Name": item.name, "Width": 4 });
                reportjson.DetailGrid.ColumnContent.ColumnContentCell.push({ "Column": item.name, "DataField": item.name });
                reportjson.DetailGrid.ColumnTitle.ColumnTitleCell.push({ "GroupTitle": false, "Column": item.name, "TextAlign": "MiddleCenter", "Text": item.label });
            });
        }
        return reportjson;
    };
    //获取表单数据
    reportController.prototype.getformdata = function () {
        var formid = TSLobsterAPI.Program.RequestQuery("formid", 0);
        var strsql = null;
        strsql = "SELECT Id	,FormId	,	FormValue	,	CreateTime	,	UpdateTime	,WriteTimeLong	,WriteDevice	,WriteOS	,WriteBrower	,WriteLocation	,WriteIP FROM PSQ_FormData where FormId=@formid";
        var dbparams = {
            formid: formid
        };
        var dataList = TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, dbparams);
        // PublicFunction.TrackLog("getformdata", 0, dataList);
        var _dataList = [];
        dataList.forEach(function (item) {
            if (item.FormValue) {
                item = TSLobsterAPI.Utils.extend(item, JSON.parse(item.FormValue));
                // PublicFunction.TrackLog("getformdata", 0, item);
                item.FormValue = "";
                _dataList.push(item);
            }
        });
        return { "Table": _dataList };
    };
    return reportController;
}());

//author:kakake
var reportDao = /** @class */ (function () {
    function reportDao() {
        this.dbConn = TSLobsterAPI.Program.GetDbConn();
    }
    return reportDao;
}());

//author:kakake
var reportService = /** @class */ (function () {
    function reportService() {
    }
    return reportService;
}());

